<?php
#print_r( $_GET);
#echo $this->_path_info[0];
#phpinfo(32);
?>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tbody>
    <tr>
      <td colspan="5" class="cattitle"><img src="<?php echo const_Static_Data_Url; ?>images/bullet_go.png" border="0" align="absmiddle" />Danh sách menu</td>
    </tr>
	<tr>
		<td colspan="5" height="1"></td>
	</tr>
	<?php
	if(is_array($arrMenu) && sizeof($arrMenu)>0){
		$i = 1;
		foreach($arrMenu as $key => $val){
	?>
    <tr class="parentmenu">
      <td colspan="2" align="left" class="txtpadding">
	  <?php
	  if($val['menu_active'] != 1){
	  ?>
		  <img src="<?php echo const_Static_Data_Url; ?>images/picture_empty.png" border="0" align="absmiddle" />
	  <?php
	  }else{
	  ?>
		  <img src="<?php echo const_Static_Data_Url; ?>images/picture_check.png" border="0" align="absmiddle" />
	  <?php
	   }
	  ?>
			  
		<?php echo $val['menu_name'] ?></td>
	  <td align="right" width="246" style="padding-right:5px;">
		<?php
		for( $ii=0, $ss=count( $Perms); $ii<$ss; ++$ii) {
			$v_perm = $this->User->getPerm( $val['menu_id'], $this->_path_info[0], $Perms[$ii]['permission_name']);
			
			$checkbox_value = '';
			$v_perm_active = $Perms[$ii]['permission_name'];
			if( $v_perm) {
				$checkbox_value = ' checked="checked"';
				$v_perm_active = 'none';
			}
		?>
			<input type='checkbox' name='fw24h_user_menu_menu_<?php echo $val['menu_id'] ?>' value='<?php echo $Perms[$ii]['permission_name']; ?>' <?php echo $checkbox_value; ?> onclick="location.href='<?php echo const_Static_Data_Url; ?>/user/permissions/<?php echo $this->_path_info[0],'?menu=',$val['menu_id'],'&permission=',$Perms[$ii]['permission_name'],'&fw24h_user_menu_id=',$v_perm['24hfw_user_menu_id'],'&newperm=',$v_perm_active; ?>'"><?php echo $Perms[$ii]['permission_name']; ?>
		<?php
		}
		?>
	  </td>
    </tr>
	<?php
			if(sizeof($val['children']) > 0){
				$x = 1;
				foreach($val['children'] as $child_key => $child_val){
	?>
			<tr class="rowsubmenu">
			  <td colspan="2" align="left" class="submenu">
			  <?php
			  if($child_val['menu_active'] != 1){
			  ?>
				  <img src="<?php echo const_Static_Data_Url; ?>images/uncheck.png" border="0" align="baseline" style="padding-left:20px;" />
			  <?php
			  }else{
			  ?>
				  <img src="<?php echo const_Static_Data_Url; ?>images/check.png" border="0" align="baseline" style="padding-left:20px;" />
			  <?php
			   }
			  ?>

					<?php echo $child_val['menu_name']; ?></td>
			  <td align="left">
					<?php
					for( $ii=0, $ss=count( $Perms); $ii<$ss; ++$ii) {
						$v_perm = $this->User->getPerm( $child_val['menu_id'], $this->_path_info[0], $Perms[$ii]['permission_name']);
						
						$checkbox_value = '';
						$v_perm_active = $Perms[$ii]['permission_name'];
						if( $v_perm) {
							$checkbox_value = ' checked="checked"';
							$v_perm_active = 'none';
						}
					?>
						<input type='checkbox' name='fw24h_user_menu_menu_<?php echo $child_val['menu_id'] ?>' value='<?php echo $Perms[$ii]['permission_name']; ?>' <?php echo $checkbox_value; ?> onclick="location.href='<?php echo const_Static_Data_Url; ?>/user/permissions/<?php echo $this->_path_info[0],'?menu=',$child_val['menu_id'],'&permission=',$Perms[$ii]['permission_name'],'&fw24h_user_menu_id=',$v_perm['24hfw_user_menu_id'],'&newperm=',$v_perm_active; ?>'"><?php echo $Perms[$ii]['permission_name']; ?>
					<?php
					}
					?>
			  </td>
			</tr>
    <?php
					$x++;
				}
			}
			$i ++;
		}
	?>
	<tr>
		<td colspan="5" height="5"></td>
	</tr>

	<?php
	}
	?>
  </tbody>
</table>
